<template>
<div class="child">
  <h2>我是Child组件</h2>
  <h3>我有一台电脑:{{computer}}</h3>
  <button @click="sendComputer">把电脑传给父组件App</button>
</div>
</template>

<script>
export default {
  name: "Child",
  data(){
    return{
      computer:'电脑联想牌'
    }
  },
  methods:{
    //$emit 触发事件
    sendComputer(){
      this.$emit('fangjiale',this.computer)
    }
  }

}
</script>

<style scoped>
.child {
  background: #bfa;
  padding: 10px;
}
</style>